package com.etennis.controller;

import com.etennis.pojos.PageResult;
import com.etennis.pojos.ResponseResult;
import com.etennis.pojos.vo.app.MatchVO;
import com.etennis.pojos.vo.web.EventVO;
import com.etennis.pojos.dto.web.MatchDTO;
import com.etennis.pojos.dto.web.MatchDetailQueryDTO;
import com.etennis.pojos.dto.web.MatchPageQueryDTO;
import com.etennis.service.IEventsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/web/match")
@Slf4j
@Api(tags = "网页端-赛事管理接口")
public class MatchController {
    @Autowired
    IEventsService iEventsService;

    @PostMapping("/save")
    @ApiOperation("新增赛事")
    public ResponseResult save(@RequestBody MatchDTO matchDTO){
        iEventsService.saveMatch(matchDTO);
        return ResponseResult.okResult();
    }

    @GetMapping("/matchDetail")
    @ApiOperation("赛事详细——比赛记录")
    public ResponseResult<List<EventVO>> matchDetail(MatchDetailQueryDTO matchDetailQueryDTO){
        List<EventVO> res=iEventsService.matchDetail(matchDetailQueryDTO);
        return ResponseResult.okResult(res);
    }

    @GetMapping("/page")
    @ApiOperation("分页展示赛事")
    public ResponseResult<PageResult<MatchVO>> page(MatchPageQueryDTO matchPageQueryDTO){
        PageResult<MatchVO> page=iEventsService.pageMatch(matchPageQueryDTO);
        return ResponseResult.okResult(page);
    }

}
